package week6;

import java.util.Arrays;

public class Ex52 {
    public static void main(String[] args) {
        char[] a1, a2, a3, a4, a5, a6;
        for (int i = 10; ; ++i){
            a1 = String.valueOf(i).toCharArray();
            a2 = String.valueOf(2*i).toCharArray();
            Arrays.sort(a1);
            Arrays.sort(a2);
            if (String.valueOf(a1).equals(String.valueOf(a2))){
                a3 = String.valueOf(3*i).toCharArray();
                Arrays.sort(a3);
                if (String.valueOf(a1).equals(String.valueOf(a3))){
                    a4 = String.valueOf(4*i).toCharArray();
                    Arrays.sort(a4);
                    if (String.valueOf(a1).equals(String.valueOf(a4))){
                        a5 = String.valueOf(5*i).toCharArray();
                        Arrays.sort(a5);
                        if (String.valueOf(a1).equals(String.valueOf(a5))){
                            a6 = String.valueOf(6*i).toCharArray();
                            Arrays.sort(a6);
                            if (String.valueOf(a1).equals(String.valueOf(a6))){
                                System.out.println(i);
                                break;
                            }
                        }
                    }
                }
            }
        }
    }
}
